package com.wcl.nullmusic.ui.fragment;

import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;
import com.wcl.nullmusic.R;
import com.wcl.nullmusic.base.BaseFragment;
import com.wcl.nullmusic.utils.BaseUtils;

import java.io.File;

import de.greenrobot.event.EventBus;

/**
 * Created by dllo on 16/1/25.
 */
public class PicFragment extends BaseFragment {
    private ImageView pic_pic;
    @Override
    protected int getLayout() {
        return R.layout.fragment_pic;
    }

    @Override
    protected void getVaule() {

    }

    @Override
    protected void initView(View view) {
        EventBus.getDefault().register(this);
        pic_pic= (ImageView) view.findViewById(R.id.pic_pic);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void listener() {

    }

    public void onEvent(String pic){
        Log.i("io","有接到的信息");
        if (!TextUtils.isEmpty(pic)) {
            if (BaseUtils.splitStr(pic))
                Picasso.with(getActivity()).load(pic).placeholder(R.mipmap.ic_live_voice_press)
                        .error(R.mipmap.ic_live_voice_press).into(pic_pic);
            else
                Picasso.with(getActivity()).load(new File(pic)).placeholder(R.mipmap.ic_live_voice_press)
                        .error(R.mipmap.ic_live_voice_press).into(pic_pic);
        } else
            pic_pic.setImageResource(R.mipmap.ic_live_voice_press);
    }

    @Override
    public void onDestroy() {
        EventBus.getDefault().unregister(this);
        super.onDestroy();
    }
}
